home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / src_1218.zip / AX25.H < prev    next >
C/C++ Source or Header  |  1991-03-16  |  8KB  |  231 lines

  1. #ifndef    _AX25_H
  2. #define    _AX25_H
  3.  
  4. #ifndef    _GLOBAL_H
  5. #include "global.h"
  6. #endif
  7.  
  8. #ifndef    _MBUF_H
  9. #include "mbuf.h"
  10. #endif
  11.  
  12. #ifndef    _IFACE_H
  13. #include "iface.h"
  14. #endif
  15.  
  16. #ifndef _SOCKADDR_H
  17. #include "sockaddr.h"
  18. #endif
  19.  
  20. /* AX.25 datagram (address) sub-layer definitions */
  21.  
  22. #define    MAXDIGIS    7    /* Maximum number of digipeaters */
  23. #define    ALEN        6    /* Number of chars in callsign field */
  24. #define    AXALEN        7    /* Total AX.25 address length, including SSID */
  25. #define    AXBUF        10    /* Buffer size for maximum-length ascii call */
  26.  
  27. #ifndef _LAPB_H
  28. #include "lapb.h"
  29. #endif
  30.  
  31. /* Bits within SSID field of AX.25 address */
  32. #define    SSID        0x1e    /* Sub station ID */
  33. #define    REPEATED    0x80    /* Has-been-repeated bit in repeater field */
  34. #define    E        0x01    /* Address extension bit */
  35. #define    C        0x80    /* Command/response designation */
  36.  
  37. /* Our AX.25 address */
  38. extern char Mycall[AXALEN];
  39.  
  40. /* List of AX.25 multicast addresses, e.g., "QST   -0" in shifted ASCII */
  41. extern char Ax25multi[][AXALEN];
  42.  
  43. extern int Digipeat;
  44. extern int Ax25mbox;
  45.  
  46. /* Number of chars in interface field. The involved definition takes possible
  47.  * alignment requirements into account, since ax25_addr is of an odd size.
  48.  */
  49. #define    ILEN    (sizeof(struct sockaddr) - sizeof(short) - AXALEN)
  50.  
  51. /* Socket address, AX.25 style */
  52. struct sockaddr_ax {
  53.     short sax_family;        /* 2 bytes */
  54.     char ax25_addr[AXALEN];
  55.     char iface[ILEN];        /* Interface name */
  56. };
  57.  
  58. /* Internal representation of an AX.25 header */
  59. struct ax25 {
  60.     char dest[AXALEN];        /* Destination address */
  61.     char source[AXALEN];        /* Source address */
  62.     char digis[MAXDIGIS][AXALEN];    /* Digi string */
  63.     int ndigis;            /* Number of digipeaters */
  64.     int nextdigi;            /* Index to next digi in chain */
  65.     int cmdrsp;            /* Command/response */
  66. };
  67.  
  68. /* C-bit stuff */
  69. #define    LAPB_UNKNOWN        0
  70. #define    LAPB_COMMAND        1
  71. #define    LAPB_RESPONSE        2
  72.  
  73. /* AX.25 routing table entry */
  74. struct ax_route {
  75.     struct ax_route *next;        /* Linked list pointer */
  76.     char target[AXALEN];
  77.     char digis[MAXDIGIS][AXALEN];
  78.     int ndigis;
  79.     char type;
  80. #define    AX_LOCAL    1        /* Set by local ax25 route command */
  81. #define    AX_AUTO        2        /* Set by incoming packet */
  82. };
  83. #define NULLAXR    ((struct ax_route *)0)
  84.  
  85. extern struct ax_route *Ax_routes;
  86. extern struct ax_route Ax_default;
  87.  
  88. /* AX.25 Level 3 Protocol IDs (PIDs) */
  89. #define PID_X25        0x01    /* CCITT X.25 PLP */
  90. #define    PID_SEGMENT    0x08    /* Segmentation fragment */
  91. #define PID_TEXNET    0xc3    /* TEXNET datagram protocol */
  92. #define    PID_LQ        0xc4    /* Link quality protocol */
  93. #define    PID_APPLETALK    0xca    /* Appletalk */
  94. #define    PID_APPLEARP    0xcb    /* Appletalk ARP */
  95. #define    PID_IP        0xcc    /* ARPA Internet Protocol */
  96. #define    PID_ARP        0xcd    /* ARPA Address Resolution Protocol */
  97. #define    PID_NETROM    0xcf    /* NET/ROM */
  98. #define    PID_NO_L3    0xf0    /* No level 3 protocol */
  99.  
  100. #define    SEG_FIRST    0x80    /* First segment of a sequence */
  101. #define    SEG_REM        0x7f    /* Mask for # segments remaining */
  102.  
  103. #define    AX_EOL        "\r"    /* AX.25 end-of-line convention */
  104.  
  105. /* Link quality report packet header, internal format */
  106. struct lqhdr {
  107.     int16 version;        /* Version number of protocol */
  108. #define    LINKVERS    1
  109.     int32    ip_addr;    /* Sending station's IP address */
  110. };
  111. #define    LQHDR    6
  112. /* Link quality entry, internal format */
  113. struct lqentry {
  114.     char addr[AXALEN];    /* Address of heard station */
  115.     int32 count;        /* Count of packets heard from that station */
  116. };
  117. #define    LQENTRY    11
  118.  
  119. /* Link quality database record format
  120.  * Currently used only by AX.25 interfaces
  121.  */
  122. struct lq {
  123.     struct lq *next;
  124.     char addr[AXALEN];    /* Hardware address of station heard */
  125.     struct iface *iface;    /* Interface address was heard on */
  126.     int32 time;        /* Time station was last heard */
  127.     int32 currxcnt;    /* Current # of packets heard from this station */
  128.  
  129. #ifdef    notdef        /* Not yet implemented */
  130.     /* # of packets heard from this station as of his last update */
  131.     int32 lastrxcnt;
  132.  
  133.     /* # packets reported as transmitted by station as of his last update */
  134.     int32 lasttxcnt;
  135.  
  136.     int16 hisqual;    /* Fraction (0-1000) of station's packets heard
  137.              * as of last update
  138.              */
  139.     int16 myqual;    /* Fraction (0-1000) of our packets heard by station
  140.              * as of last update
  141.              */
  142. #endif
  143. };
  144. #define    NULLLQ    (struct lq *)0
  145.  
  146. extern struct lq *Lq;    /* Link quality record headers */
  147.  
  148. /* Structure used to keep track of monitored destination addresses */
  149. struct ld {
  150.     struct ld *next;    /* Linked list pointers */
  151.     char addr[AXALEN];/* Hardware address of destination overheard */
  152.     struct iface *iface;    /* Interface address was heard on */
  153.     int32 time;        /* Time station was last mentioned */
  154.     int32 currxcnt;    /* Current # of packets destined to this station */
  155. };
  156. #define    NULLLD    (struct ld *)0
  157.  
  158. extern struct ld *Ld;    /* Destination address record headers */
  159.  
  160. /* Linkage to network protocols atop ax25 */
  161. struct axlink {
  162.     int pid;
  163.     void (*funct) __ARGS((struct iface *,struct ax25_cb *,char *, char *,
  164.      struct mbuf *,int));
  165. };
  166. extern struct axlink Axlink[];
  167.  
  168. /* Codes for the open_ax25 call */
  169. #define    AX_PASSIVE    0
  170. #define    AX_ACTIVE    1
  171. #define    AX_SERVER    2    /* Passive, clone on opening */
  172.  
  173. /* In ax25.c: */
  174. struct ax_route *ax_add __ARGS((char *,int,char digis[][AXALEN],int));
  175. int ax_drop __ARGS((char *));
  176. struct ax_route *ax_lookup __ARGS((char *));
  177. void ax_recv __ARGS((struct iface *,struct mbuf *));
  178. int ax_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int prec,
  179.     int del,int tput,int rel));
  180. int ax_output __ARGS((struct iface *iface,char *dest,char *source,int16 pid,
  181.     struct mbuf *data));
  182. int sendframe __ARGS((struct ax25_cb *axp,int cmdrsp,int ctl,struct mbuf *data));
  183. void axnl3 __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  184.     char *dest,struct mbuf *bp,int mcast));
  185.  
  186. /* In ax25cmd.c: */
  187. void st_ax25 __ARGS((struct ax25_cb *axp));
  188.  
  189. /* In axhdr.c: */
  190. struct mbuf *htonax25 __ARGS((struct ax25 *hdr,struct mbuf *data));
  191. int ntohax25 __ARGS((struct ax25 *hdr,struct mbuf **bpp));
  192.  
  193. /* In axlink.c: */
  194. void getlqentry __ARGS((struct lqentry *ep,struct mbuf **bpp));
  195. void getlqhdr __ARGS((struct lqhdr *hp,struct mbuf **bpp));
  196. void logsrc __ARGS((struct iface *iface,char *addr));
  197. void logdest __ARGS((struct iface *iface,char *addr));
  198. char *putlqentry __ARGS((char *cp,char *addr,int32 count));
  199. char *putlqhdr __ARGS((char *cp,int16 version,int32 ip_addr));
  200. struct lq *al_lookup __ARGS((struct iface *ifp,char *addr,int sort));
  201.  
  202. /* In ax25user.c: */
  203. int ax25val __ARGS((struct ax25_cb *axp));
  204. int disc_ax25 __ARGS((struct ax25_cb *axp));
  205. int kick_ax25 __ARGS((struct ax25_cb *axp));
  206. struct ax25_cb *open_ax25 __ARGS((struct iface *,char *,char *,
  207.     int,int16,
  208.     void (*) __ARGS((struct ax25_cb *,int)),
  209.     void (*) __ARGS((struct ax25_cb *,int)),
  210.     void (*) __ARGS((struct ax25_cb *,int,int)),
  211.     int user));
  212. struct mbuf *recv_ax25 __ARGS((struct ax25_cb *axp,int16 cnt));
  213. int reset_ax25 __ARGS((struct ax25_cb *axp));
  214. int send_ax25 __ARGS((struct ax25_cb *axp,struct mbuf *bp,int pid));
  215.  
  216. /* In ax25subr.c: */
  217. int addreq __ARGS((char *a,char *b));
  218. struct ax25_cb *cr_ax25 __ARGS((char *addr));
  219. void del_ax25 __ARGS((struct ax25_cb *axp));
  220. struct ax25_cb *find_ax25 __ARGS((char *));
  221. char *pax25 __ARGS((char *e,char *addr));
  222. int setcall __ARGS((char *out,char *call));
  223.  
  224. /* In socket.c: */
  225. void beac_input __ARGS((struct iface *iface,char *src,struct mbuf *bp));
  226. void s_arcall __ARGS((struct ax25_cb *axp,int cnt));
  227. void s_ascall __ARGS((struct ax25_cb *axp,int old,int new));
  228. void s_atcall __ARGS((struct ax25_cb *axp,int cnt));
  229.  
  230. #endif  /* _AX25_H */
  231.